
const {ccclass, property} = cc._decorator;

@ccclass
export default class Grid extends cc.Component {

    @property(cc.Node)
    bg:cc.Node = null;

    private clickCb: (atype:number)=>void;
    private atype = 0;
    private id = "0";
    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    start () {

    }

    update(){
        if(this.node.y<-300){
            this.node.destroy();
            if(this.atype==1){
                this.node.parent.getComponent("Helloworld").gameOver();
            }
        }
    }
    //
    setData(id:string,atype:number,clickCb){
        this.id = id;
        this.atype = atype;
        this.clickCb = clickCb;
        if(atype==1){
            this.bg.color = cc.color(0, 255, 69);
        }
    }
    // update (dt) {}
    clickButton(){
        this.clickCb(this.atype);
    }
}
